home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbtype1a / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-08-28  |  2.0 KB  |  66 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BackColor       =   &H00000000&
  4.    Caption         =   "The VB Typewriter"
  5.    ClientHeight    =   3195
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   4680
  9.    BeginProperty Font 
  10.       Name            =   "Fixedsys"
  11.       Size            =   9
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    LinkTopic       =   "Form1"
  19.    ScaleHeight     =   3195
  20.    ScaleWidth      =   4680
  21.    StartUpPosition =   3  'Windows Default
  22. Attribute VB_Name = "Form1"
  23. Attribute VB_GlobalNameSpace = False
  24. Attribute VB_Creatable = False
  25. Attribute VB_PredeclaredId = True
  26. Attribute VB_Exposed = False
  27. ' This is the typewriter object
  28. Dim myTyper As New Typer
  29. Dim curString As String
  30. Private Sub Form_Load()
  31.     ' CurTime is the current time
  32.     ' NextTime is when we should next execute
  33.     Dim CurTime As Long, NextTime As Long
  34.     ' Make sure we give VB time to show the form
  35.     Me.Show
  36.     ' Set the NextTime to the current time + 50ms
  37.     NextTime = timeGetTime() + 50
  38.     myTyper.Y = 12
  39.     curString = "This is the VB TypeWriter....."
  40.     ' Main loop
  41.     Do While DoEvents()
  42.         ' Get the current time
  43.         CurTime = timeGetTime()
  44.         
  45.         ' If the current time is up to or past NextTime
  46.         If CurTime >= NextTime Then
  47.             ' Clear the form
  48.             Me.Cls
  49.         
  50.             ' Do the call
  51.             res = myTyper.Draw(Me.hDC, curString, RGB(0, 255, 0))
  52.             If res = TW_STILLTYPING Then
  53.                 ' Set the next time the loop is executed
  54.                 If myTyper.CurCharNo > 25 Then
  55.                     NextTime = NextTime + 500
  56.                 Else
  57.                     NextTime = NextTime + 50
  58.                 End If
  59.             ElseIf res = TW_DONETYPING Then
  60.                 NextTime = NextTime + 1000
  61.             End If
  62.         End If
  63.         
  64.     Loop
  65. End Sub
  66.